<template>
<div class="register">
    <h2>注册</h2>
    <van-form @submit="onSubmit">
  <van-field
    v-model="username"
    class="input input1"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    class="input"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" class="login1" native-type="submit">注册</van-button>
  </div>
</van-form>
</div>
</template>
<script>
import {reqRegister} from "../../api/reqReg";
export default {
data() {
return {
    username: '',
    password: '',
};
},
computed: {},
watch: {},
methods: {
    async onSubmit(values) {
      console.log("submit", values);
      const result = await reqRegister({
        userName: this.username,
        password: this.password,
      });
      console.log(result);
      if (result.code == "success") {
        this.$router.push("/login");
      } else {
        alert(result.message);
      }
    },
},
created() {},
mounted() {},
components: {},
};
</script>
<style scoped>
*{
   margin: 0;
  padding: 0; 
}
.register{
  width: 100%;
  height: 700px;
background: url("./imgs/bgt1.png") no-repeat center/cover;
opacity: 0.7;
overflow: hidden;
}

h2{
  margin: 20px auto;
  width: 100%;
  text-align: center;
}
.input{
  width: 100%;
  height: 60px;
  line-height: 60px;
  text-indent: 10px;
  background: rgba(255, 255, 255, 0.36);
  font-size: 20px;
}
.login1{
  margin-top: 40px;
}
</style>